<?php include (dirname(__FILE__)."/../include/header.php"); ?>
<?php if(!isset($_SESSION['_user'])){header("location:../user_login.php");}?>
<?php
	$sql="SELECT zy_food.*,zy_shop.`shop_name`,zy_shop.shop_id FROM zy_food,zy_favofood,zy_shop WHERE zy_food.shop_id=zy_shop.`shop_id` AND zy_food.food_id = zy_favofood.food_id AND zy_favofood.user_id = '".$_SESSION['_user']['user_id']."'";
	$rs=mysql_query($sql);
	$total_favo=mysql_num_rows($rs);
?>

<div class="container">
<ul class="breadcrumb">
  <li><a href="<?php echo SITE_ROOT; ?>">返回首页</a><span class="divider">/</span></li>
 <li><a href="<?php echo SITE_ROOT."/user/favo_store.php"; ?>">我收藏的美食</a></li>
</ul>
<div class="row">
  <div class="span12 wash-paper profile">
    <div class="row">
      <div class="span3">
        <?php include (dirname(__FILE__)."/../include/user/left.php"); ?>
        <div class="span9">
          <div class="main-content">
            <div class="content-header">
              <h3>我收藏的美食 - 共<span id="total-favo-food"><?php echo $total_favo;?></span>个</h3>
            </div>
            <div class="content-inner">
              <table class="favor_table table table-striped">
                <thead>
                  <tr>
                    <th>美食</th>
                    <th>所属餐厅</th>
                    <th>单价</th>
                    <th>删除</th>
                  </tr>
                </thead>
                <tbody>
                  <?php while($food=mysql_fetch_array($rs)){?>
                  <tr class="favor_food" >
                    <td><?php echo $food['food_name'];?></td>
                    <td><a href="<?php echo SITE_ROOT."/index_shop.php?shop_id=".$food['shop_id'] ?>"><?php echo $food['shop_name'];?></a></td>
                    <td><?php echo $food['price'];?>元</td>
                    <td><span class="admin_del" foodId="<?php echo $food['food_id'];?>"> <a href="javascript:;">删除</a> </span> </td>
                  </tr>
                  <?php } ?>
                </tbody>
              </table>
              <div> </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <a id="back-to-top" href="javascript:void(0);">
  <div class="backtotop"></div>
  </a> </div>
<?php include (dirname(__FILE__)."/../include/footer.php"); ?>
<script type="text/javascript">
$(document).ready(function(){
	$(".admin_del").click(function(){
		var row=$(this).parent().parent();
		$.ajax({
            type: "post",
            url: "../include/zy_function.php",
			data:{method:"unFavoFood",food_id:$(this).attr("foodId")},
            dataType: "json",
            success: function(){
            	row.remove();
            	$("#total-favo-food").html($("#total-favo-food").html()-1);
            }
         });
	});
});
</script>